package org.ourgrid.discoveryservice.business.requester;

import java.util.ArrayList;
import java.util.List;

import org.ourgrid.common.internal.IResponseTO;
import org.ourgrid.common.internal.RequesterIF;
import org.ourgrid.discoveryservice.business.dao.DiscoveryServiceDAO;
import org.ourgrid.discoveryservice.business.dao.DiscoveryServiceDAOFactory;
import org.ourgrid.discoveryservice.request.DSClientGetDiscoveryServicesRequestTO;
import org.ourgrid.discoveryservice.response.DSClientHereAreDiscoveryServicesResponseTO;

public class DSClientGetDiscoveryServicesRequester implements RequesterIF<DSClientGetDiscoveryServicesRequestTO>{
	
	public List<IResponseTO> execute(DSClientGetDiscoveryServicesRequestTO request) {
		List<IResponseTO> responses = new ArrayList<IResponseTO>();
		
		DiscoveryServiceDAO discoveryServiceDAO = DiscoveryServiceDAOFactory.getInstance().getDiscoveryServiceDAO();
		
		DSClientHereAreDiscoveryServicesResponseTO to = new DSClientHereAreDiscoveryServicesResponseTO();
		to.setDiscoveryServices(discoveryServiceDAO.getDiscoveryServicesAddresses());
		to.setStubAddress(request.getClientAddress());
		
		responses.add(to);
		
		return responses;
	}
	
}
